package ru.ifmo.thesis.domain;

import ru.ifmo.thesis.quantities.Minutes;
import ru.ifmo.thesis.quantities.Money;

public class ContractOptions {

	private PenaltyFunction penaltyFunction;
	
	public ContractOptions(int minutesBeforePenalty, double initialPenalty,
			double factor) {
		this.penaltyFunction = new LinearPenaltyFunction(
				new Minutes(minutesBeforePenalty),
				new Money(initialPenalty),
				factor);
	}
	
	public PenaltyFunction getPenaltyFunction() {
		return penaltyFunction;
	}

	@Override
	public String toString() {
			return "{class=\"Contract options\",penaltyFunction=" + penaltyFunction.toString() + " }";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((penaltyFunction == null) ? 0 : penaltyFunction.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContractOptions other = (ContractOptions) obj;
		if (penaltyFunction == null) {
			if (other.penaltyFunction != null)
				return false;
		} else if (!penaltyFunction.equals(other.penaltyFunction))
			return false;
		return true;
	}
	
	
}
